import { createStore } from 'vuex'

const store = createStore({
	state(){
		return {
			token:'',
			header:'',
			navList:null
		}
	},
	mutations:{
		setToken(state,payload) {
			state.token = payload.token;
		},
		setHeader(state,payload) {
			state.header = payload.header;
		},
		pushNav(state,payload) {
			if(state.navList === null) {
				state.navList = new Map();
			} 
			state.navList.set(payload.nav.path,payload.nav);
		},
		delNav(state,payload) {
			state.navList.delete(payload.nav[0]);
		}
	}
})

export default store